<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/23
 * Time: 13:53
 */

namespace app\admin\controller;

use app\common\controller\Common;
use think\Model;
use think\Request;

class Base extends Common
{
    public function login()
    {
        $userModel = model('User');
        $param = $this->param;
        $username = $param['username'];
        $password = $param['password'];

        $data =  $userModel->login($username, $password);
        if (!$data) {
            return resultJson(['error' => $userModel->getError()]);
        }
        return resultJson(['data' => $data]);
    }

    public function logout()
    {
        $param = $this->param;
        cache('Auth_'.$param['authkey'], null);
        return resultJson(['data'=>'退出成功']);
    }

    // miss 路由：处理没有匹配到的路由规则
    public function miss()
    {
        if (Request::instance()->isOptions()) {
            return ;
        } else {
            echo 'ok-wbz';
        }
    }
}